<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cn.entity.DepInfo" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.cn.entity.BookInfo" %>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cn.*" %>
<%@ page import="com.cn.entity.BookUnion" %>
<%@ page import="com.cn.entity.Newsclass" %>
<%@ page import="com.cn.Dao.*" %>
<jsp:include page="WEB-INF/header/header-admin.jsp"/>
<jsp:useBean id="userInfo" class="com.cn.entity.UserInfo" scope="session"/>
<%
//    BookDao bookDao=new BookDao();
    List<BookUnion> bookUnions= (List<BookUnion>) request.getSession().getAttribute("bookUnions");

//    bookUnions=bookDao.findAllUnion();
//    List<Newsclass> newsclasses=new ArrayList<>();

%>

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/img/logo2.png" type="image/x-icon">
</head>
<body>
<div class="container-fluid">
    <form action="SearchBookServlet" method="post">
    <div class="row">
        <div class="col-md-2">
            <div class="row">
                <div class="col-md-4">
                    <label class="float-right">报刊</label>
                </div>
<%--                <div class="col-md-8">--%>
<%--                    <input type="text"class="input-group"/>--%>
<%--                </div>--%>
                <div class="col-xs-9 text-left">
                    <input type="text"  name="bk">
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="row">
                <div class="col-md-4">
                    <label class="float-right">用户</label>
                </div>
                <div class="col-xs-9 text-left">
                    <input type="text"  name="yh">
                </div>
            </div>
        </div>
        <div class="col-md-2">
            <div class="row">
                <div class="col-md-6">
                    <label class="float-right">部门</label>
                </div>
                <div class="col-xs-9 text-left">
                    <select id="dep" name="dep">
                        <option selected></option>
                        <c:forEach items="${depInfos}" var="depInfo">
                            <option value="${depInfo.getDepartmentid()}">${depInfo.getDname()}</option>
                        </c:forEach>
                    </select>
<%--                        <%for(int i=0;i<depInfos.size();i++){%>--%>
<%--                            <option value="<%=depInfos.get(i).getDepartmentid()%>"><%=depInfos.get(i).getDname()%></option>--%>
<%--                        <%}%>--%>



                </div>
            </div>
        </div>
        <div class="col-md-1" class="float-left">
            <div class="row">
                <div class="col-md-6">
                    <label class="float-right">状态</label>
                </div>
                <div class="col-xs-9 text-left">
                    <select name="state" class="custom-select" style="min-width: 100px">
                        <option value=""></option>
                        <option value="1">接受</option>
                        <option value="0">拒绝</option>
                        <option value="2">未处理</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="col-md-2">
            <br/>
            <button class="btn btn-primary btn-large" type="submit" name="submit">搜索</button>
        </div>
        <a href="printBookPage.jsp" target="_blank">
            <div class="col-md-2">
                <br/>
                <button class="btn btn-primary btn-large" type="button">打印预览</button>
            </div>
        </a>
    </div>
    </form>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>
                        #
                    </th>
                    <th>
                        User
                    </th>
                    <th>
                        Newspaper
                    </th>
                    <th>
                        Price
                    </th>
                    <th>
                        State
                    </th>
                </tr>
                </thead>
                <tbody>
                <%for(int i=0;i<bookUnions.size();i++){%>
                    <tr onclick="trClick('<%=bookUnions.get(i).getBid()%>')">
                        <td>
                            <%=bookUnions.get(i).getBid()%>
                        </td>
                        <td>
                            <%=bookUnions.get(i).getUsername()%>
                        </td>
                        <td>
                            <%=bookUnions.get(i).getNewsname()%>
                        </td>
                        <td>
                            <%=bookUnions.get(i).getPrice()%>
                        </td>
                        <td>
                            <%if (bookUnions.get(i).getState()==0)
                                out.print("拒绝");
                            else if (bookUnions.get(i).getState()==1)
                                out.print("接受");
                            else if (bookUnions.get(i).getState()==2)
                            out.print("未处理");
                            %>
<%--                            <%=bookInfos.get(i).getState()%>--%>
                        </td>
                    </tr>
                <%}%>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
<script language ="javascript">
    function trClick(strURL)
    {
        window.location = "BookDetailServlet?id="+strURL;
    }
</script>
</body>
</html>


